<%@ taglib uri="/tags/struts-bean" prefix="bean"%>
<%@ taglib uri="/tags/struts-html" prefix="html"%>
<%@ taglib uri="/tags/struts-logic" prefix="logic"%>
<%@ taglib uri="/tags/core" prefix="c"%>
<%@ taglib uri="/tags/fmt" prefix="fmt"%>
<%@ taglib uri="/WEB-INF/tld/security.tld" prefix="s" %>

<script type="text/javascript" src="js/utils.js"></script>
<script type="text/javascript">
function submitPlantQuery(form, orderField, orderType){
		form.orderField.value = orderField;
		form.orderType.value = orderType;
		form.action = "listPlantsQuery.do";
		if (validSubmit){
			form.submit();
		} else {
			alert('<fmt:message key="warning.message.common.processing"/>');
		}
	}
</script>
<html:form action="/listPlantsQuery" method="POST">
	<html:hidden property="orderField"/>
	<html:hidden property="orderType"/>
</html:form>
<table align="center" cellpadding="2" cellspacing="1" border="0" bgcolor="#CCCCC0">
	<tr>
		<td class="titulocolumna" align="center" width="20">
			<html:link action="/goAddPlants.do"><img alt="<bean:message key="label.common.add"/> <bean:message key="label.plants.name"/>" src="images/nuevo.gif" border="0"></html:link>
		</td>
		<td class="titulocolumna" align="center" width="110">
			<a href="#>" onclick="return submitPlantQuery(document.PlantsQueryForm, 0, '<c:choose><c:when test="${previousOrderField == 0 && previousOrderType == 0}">1</c:when><c:otherwise>0</c:otherwise></c:choose>');" class="ligas">
				<bean:message key="label.plants.table.column.id"/>
				<c:choose>
					<c:when test="${previousOrderField == 0 && previousOrderType == 1}">
						<img alt="<bean:message key="label.common.order.ascending"/>" src="images/arrow_up.gif" border="0"/>
					</c:when>
					<c:when test="${previousOrderField == 0 && previousOrderType == 0}">
						<img alt="<bean:message key="label.common.order.descending"/>" src="images/arrow_down.gif" border="0"/>
					</c:when>
				</c:choose>
			</a>	
		</td>
		<td class="titulocolumna" align="center" width="70">
			<s:entidad nombreCortoMod="CATALOG" nombreCortoSub="PLANT" nombreCortoEnt="NEW" permiso="ADMINISTRACION">
				<a href="#>" onclick="return submitPlantQuery(document.PlantsQueryForm, 1,'<c:choose><c:when test="${previousOrderField == 1 && previousOrderType == 0}">1</c:when><c:otherwise>0</c:otherwise></c:choose>');" class="ligas">
					<bean:message key="label.plants.table.column.code"/>
					<c:choose>
						<c:when test="${previousOrderField == 1 && previousOrderType == 1}">
							<img alt="<bean:message key="label.common.order.ascending"/>" src="images/arrow_up.gif" border="0"/>
						</c:when>
						<c:when test="${previousOrderField == 1 && previousOrderType == 0}">
							<img alt="<bean:message key="label.common.order.descending"/>" src="images/arrow_down.gif" border="0"/>
						</c:when>
					</c:choose>
				</a>
			</s:entidad>
		</td>
		<td class="titulocolumna" align="center" width="150">
			<a href="#>" onclick="return submitPlantQuery(document.PlantsQueryForm, 2, '<c:choose><c:when test="${previousOrderField == 2 && previousOrderType == 0}">1</c:when><c:otherwise>0</c:otherwise></c:choose>');" class="ligas">
				<bean:message key="label.plants.table.column.description"/>
				<c:choose>
					<c:when test="${previousOrderField == 2 && previousOrderType == 1}">
						<img alt="<bean:message key="label.common.order.ascending"/>" src="images/arrow_up.gif" border="0"/>
					</c:when>
					<c:when test="${previousOrderField == 2 && previousOrderType == 0}">
						<img alt="<bean:message key="label.common.order.descending"/>" src="images/arrow_down.gif" border="0"/>
					</c:when>
				</c:choose>
			</a>	
		</td>
		<td class="titulocolumna" align="center" width="100">
			<a href="#>" onclick="return submitPlantQuery(document.PlantsQueryForm, 3, '<c:choose><c:when test="${previousOrderField == 3 && previousOrderType == 0}">1</c:when><c:otherwise>0</c:otherwise></c:choose>');" class="ligas">
				<bean:message key="label.plants.table.column.storage.amount"/>
				<c:choose>
					<c:when test="${previousOrderField == 3 && previousOrderType == 1}">
						<img alt="<bean:message key="label.common.order.ascending"/>" src="images/arrow_up.gif" border="0"/>
					</c:when>
					<c:when test="${previousOrderField == 3 && previousOrderType == 0}">
						<img alt="<bean:message key="label.common.order.descending"/>" src="images/arrow_down.gif" border="0"/>
					</c:when>
				</c:choose>
			</a>
		</td>
		<td class="titulocolumna" align="center" width="100">
			<a href="#>" onclick="return submitPlantQuery(document.PlantsQueryForm, 4, '<c:choose><c:when test="${previousOrderField == 4 && previousOrderType == 0}">1</c:when><c:otherwise>0</c:otherwise></c:choose>');" class="ligas">
				<bean:message key="label.plants.table.column.unload.amount"/>
				<c:choose>
					<c:when test="${previousOrderField == 4 && previousOrderType == 1}">
						<img alt="<bean:message key="label.common.order.ascending"/>" src="images/arrow_up.gif" border="0"/>
					</c:when>
					<c:when test="${previousOrderField == 4 && previousOrderType == 0}">
						<img alt="<bean:message key="label.common.order.descending"/>" src="images/arrow_down.gif" border="0"/>
					</c:when>
				</c:choose>
			</a>	
		</td>
		<td class="titulocolumna" align="center" width="150">
			<a href="#>" onclick="return submitPlantQuery(document.PlantsQueryForm, 5, '<c:choose><c:when test="${previousOrderField == 5 && previousOrderType == 0}">1</c:when><c:otherwise>0</c:otherwise></c:choose>');" class="ligas">
				<bean:message key="label.plants.table.column.protection.days"/>
				<c:choose>
					<c:when test="${previousOrderField == 5 && previousOrderType == 1}">
						<img alt="<bean:message key="label.common.order.ascending"/>" src="images/arrow_up.gif" border="0"/>
					</c:when>
					<c:when test="${previousOrderField == 5 && previousOrderType == 0}">
						<img alt="<bean:message key="label.common.order.descending"/>" src="images/arrow_down.gif" border="0"/>
					</c:when>
				</c:choose>
			</a>	
		</td>
		<td class="titulocolumna" align="center" width="80">
			<a href="#>" onclick="return submitPlantQuery(document.PlantsQueryForm, 6, '<c:choose><c:when test="${previousOrderField == 6 && previousOrderType == 0}">1</c:when><c:otherwise>0</c:otherwise></c:choose>');" class="ligas">
				<bean:message key="label.plants.table.column.priority"/>
				<c:choose>
					<c:when test="${previousOrderField == 6 && previousOrderType == 1}">
						<img alt="<bean:message key="label.common.order.ascending"/>" src="images/arrow_up.gif" border="0"/>
					</c:when>
					<c:when test="${previousOrderField == 6 && previousOrderType == 0}">
						<img alt="<bean:message key="label.common.order.descending"/>" src="images/arrow_down.gif" border="0"/>
					</c:when>
				</c:choose>
			</a>	
		</td>
		<td width="20" class="titulocolumna" align="center">&nbsp;</td>
	</tr>
	<logic:notEmpty name="listPlantViews">
		<logic:iterate id="row" name="listPlantViews" indexId="int_i">
			<tr class="<%=((int_i.intValue()%2)==0?"columnadatoPar":"columnadatoNon")%>">							
				<td align="center">
					<s:entidad nombreCortoMod="CATALOG" nombreCortoSub="PLANT" nombreCortoEnt="EDIT" permiso="ADMINISTRACION">
						<html:link action="/goEditPlants.do" paramId="plantId" paramName="row" paramProperty="plantId"> <img alt="<bean:message key="common.edit"/> <bean:write name="row" property="shortName"/>" src="images/modificar.gif" border="0"> </html:link>
					</s:entidad>
				</td>
				<td align="center"><bean:write name="row" property="plantId"/></td>
				<td align="center"><bean:write name="row" property="shortName"/></td>
				<td align="left"><bean:write name="row" property="description"/></td>
				<td align="right"><c:if test="${row.storageAmount != 0.0}"><bean:write name="row" property="storageAmount" format="###,##0.000"/></c:if></td>
				<td align="right"><c:if test="${row.unloadAmount != 0.0}"><bean:write name="row" property="unloadAmount"  format="#,##0.000"/></c:if></td>		
				<td align="right"><bean:write name="row" property="grindProtectionDays"/></td>
				<td align="right"><bean:write name="row" property="priority"/></td>
				<td align="center">
					<s:entidad nombreCortoMod="CATALOG" nombreCortoSub="PLANT" nombreCortoEnt="DELETE" permiso="ADMINISTRACION">
						<a href="#>" onclick="if( confirmDelete('<bean:write name="row" property="shortName"/>') )location.href='delPlant.do?plantId=<bean:write name="row" property="plantId"/>';"><img alt="<bean:message key="common.delete"/>  <bean:write name="row" property="shortName"/>" src="images/eliminar.jpg" border="0"></a>
					</s:entidad>
				</td>
			</tr>
		</logic:iterate>
	</logic:notEmpty>
</table>
<br />
<br />